package com.jky.stmall.front.mapper;

import com.jky.stmall.front.entity.Addr;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AddrMapper {
    //添加
    @Insert({
            "insert into addr",
            "(contact,phone,province,city,country,town,detail,user_id)",
            "value(#{contact},#{phone},#{province},#{city},#{country},#{town},#{detail},#{userId})",
    })
    int insert(Addr addr);
    //删除
    @Delete("delete from addr where id=#{id}")
    int delete(Integer id);
    //修改
    @Update({
            "update addr",
            "set contact=#{contact},phone=#{phone},province=#{province}" +
                    "city=#{city},country=#{country},town=#{town},detail=#{detail},user_id={userId}" +
                    "status=#{status}",
            "where id=-#{id}",
    })
    int update(Addr addr);

    @Select("select * from addr where user_id=#{userId}")
    //查询
    List<Addr> selectByUserId(Integer userId);


    //查询 根据ID查询
    @Select("select * from addr where id=#{id}")
    Addr selectById(Integer id);
}
